package com.sm.imlibrary.imsdk;

import com.sm.imlibrary.nio.LoginCallbackListener;
import com.sm.imlibrary.nio.SocketIoManage;

import java.util.HashSet;
import java.util.Set;

/**
 * created by zhud on 2019/7/9
 */
public class SIMManager {
    private static SIMManager mTimManager;
    private HashSet<SIMMessageListener> msgListeners = new HashSet();
    private HashSet<SIMMessageUpdateListener> msgUpdateListeners = new HashSet();

    private SIMManager() {
    }

    public static SIMManager getInstance() {
        if (mTimManager == null) mTimManager = new SIMManager();
        return mTimManager;
    }

    public void addMessageListener(SIMMessageListener listener) {
        msgListeners.add(listener);
    }

    public void removeMessageListener(SIMMessageListener listener) {
        msgListeners.remove(listener);
    }

    Set<SIMMessageListener> getMessageListeners() {
        return this.msgListeners;
    }

    public void addMessageUpdateListener(SIMMessageUpdateListener listener) {
        this.msgUpdateListeners.add(listener);
    }

    public void removeMessageUpdateListener(SIMMessageUpdateListener listener) {
        this.msgUpdateListeners.remove(listener);
    }

    Set<SIMMessageUpdateListener> getMessageUpdateListeners() {
        return this.msgUpdateListeners;
    }

    public void login(String token, LoginCallbackListener loginCallbackListener) {
        SocketIoManage.getInstance().login(token, loginCallbackListener);
    }

    public void stop() {
        SocketIoManage.getInstance().stop();
    }

    public SIMConversation getConversation(SIMConversationType var1, String var2) {
        return new SIMConversation(var2).setType(var1);
    }
}
